﻿@using MvcPaging
@model MvcPaging.IPagedList<EagleProject.LinQDataContext.Eventt>

@{
    var controller = this.ViewContext.Controller as EagleProject.Controllers.MyController;
}

<table class="table table-bordered table-hover">
    <thead>
        <tr>
            <th>ID</th>
            <th>Name</th>
            <th>Location</th>
            <th>Partner</th>
            <th>Local Gov</th>
            <th>@if (controller.IsAdmin())
                {
                <a>Control</a>
                }
            </th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model)
        { 
            <tr>
                <td>
                    @item.ID
                </td>
                <td>
                    @item.Name
                </td>
                <td>
                    @item.Location
                </td>
                <td>
                    @item.Partner.Name
                </td>
                <td>
                    @item.LocalGovArea.Name
                </td>
                <td>
                    @if (controller.IsAdmin())
                    {
                        @Html.ActionLink("Edit", "EditEvent", "Admin", new { id = item.ID }, null)
                    }
                </td>
            </tr>
        }
    </tbody>
</table>
<div class="pager1">
    @Html.Raw(Ajax.Pager(
            new Options
            {
                PageSize = Model.PageSize,
                TotalItemCount = Model.TotalItemCount,
                CurrentPage = Model.PageNumber,
                ItemTexts = new ItemTexts() { Next = "Next", Previous = "Previous", Page = "P" },
                ItemIcon = new ItemIcon() { First = "icon-backward", Previous = "icon-chevron-left", Next = "icon-chevron-right", Last = "icon-forward" },
                TooltipTitles = new TooltipTitles() { Next = "Next page", Previous = "Previous page", Page = "Page {0}." },
                Size = Size.normal,
                Alignment = Alignment.centered,
                IsShowControls = true,
                IsShowFirstLast = true,
                CssClass = ""
            },
            new AjaxOptions
            {
                UpdateTargetId = "grid-list",
                OnBegin = "beginPaging",
                OnSuccess = "successPaging",
                OnFailure = "failurePaging"
            }, new { controller = "Admin", action = "ListEvent" }))
    <div class="well">
        Showing <span class="badge badge-success">@Model.ItemStart</span> to <span class="badge badge-success">@Model.ItemEnd</span>
        of <span class="badge badge-info">@Model.TotalItemCount</span> entries
    </div>
</div>
<script src="../../Scripts/bootstrap.min.js" type="text/javascript"></script>
